<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link type="text/css" rel="stylesheet" href="css/login.css"/>
    <title>忘记密码-确认账户</title>
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var username;
            /**
             * 进入安全认证
             */
            $("#next1-2").click(function () {
                var login=$("[name='loginword']").val();
                var captcha=$("[name='captcha']").val();
                var email=/^(?:\w+\.?)*\w+@(?:\w+\.)*\w+$/;
                var phone=/^1[34578][0-9]{9}$/;
                if(email.test(login)){
                    email=login;
                    $.get("User/forgetlogin",{"email":email},function (user) {
                        if(user.length!=0){
                            username=user.username;
                            alert("寻找到该用户可以继续");
                            $("[title='asa4']").append("验证码发送到您的手机:"+user.phone);//小瑕疵
                            $("[title='asa5']").append("用户名:"+user.username);
                            $("[title='asa6']").append(user.username);
                            let stepIndex = $("#next1-2").attr("step_index");
                            let stepId = '#step_' + stepIndex;
                            stepIndex++;
                            let divNextId = '#step_div_' + stepIndex;
                            let stepNextId = '#step_' + stepIndex;
                            $(stepId).hide();
                            $(stepNextId).show();
                            $(divNextId).addClass("Active");
                        }else {
                            alert("未找到该用户,请重新输入")
                            $("[name='captcha']").empty();
                            window.location.href = "http://127.0.0.1:8080/password.html";
                        }
                    });
                }else if(phone.test(login)){
                    phone=login;
                    $.get("User/forgetlogin",{"phone":phone},function (user) {
                        if(user.length!=0){
                            username=user.username;
                            alert("寻找到该用户可以继续");
                            $("[title='asa4']").append("验证码发送到您的手机:"+user.phone);//小瑕疵
                            $("[title='asa5']").append("用户名:"+user.username);
                            $("[title='asa6']").append(user.username);
                            let stepIndex = $("#next1-2").attr("step_index");
                            let stepId = '#step_' + stepIndex;
                            stepIndex++;
                            let divNextId = '#step_div_' + stepIndex;
                            let stepNextId = '#step_' + stepIndex;
                            $(stepId).hide();
                            $(stepNextId).show();
                            $(divNextId).addClass("Active");
                        }else {
                            alert("未找到该用户,请重新输入")
                            $("[name='captcha']").empty();
                            window.location.href = "http://127.0.0.1:8080/password.html";
                        }
                    });
                }else {
                    /*alert("格式不对请重新输入");
                    $("[name='loginword']").empty();
                    window.location.href = "http://127.0.0.1:8888/password.html";*/
                    username=login;
                    $.get("User/forgetlogin",{"username":username},function (user) {
                        username=user.username;
                        if(user.length!=0){
                            alert("寻找到该用户可以继续");
                            $("[title='asa4']").append("验证码发送到您的手机:"+user.phone);//小瑕疵
                            $("[title='asa5']").append("用户名:"+user.username);
                            $("[title='asa6']").append(user.username);
                            let stepIndex = $("#next1-2").attr("step_index");
                            let stepId = '#step_' + stepIndex;
                            stepIndex++;
                            let divNextId = '#step_div_' + stepIndex;
                            let stepNextId = '#step_' + stepIndex;
                            $(stepId).hide();
                            $(stepNextId).show();
                            $(divNextId).addClass("Active");
                        }else {
                            alert("未找到该用户,请重新输入");
                            $("[name='login']").empty();
                            window.location.href = "http://127.0.0.1:8080/password.html";
                        }
                    });
                }
                if(captcha==2399){
                    alert("验证成功");
                }else {
                    alert("验证码不匹配，请重新输入");
                    $("[name='captcha']").empty();
                    window.location.href = "http://127.0.0.1:8080/password.html";
                }
            });


            /**
             * 重置密码
             */
            $("#next2-3").click(function () {
                var sms1=$("[name='sms']").val();
                if(sms1==9172){
                    alert("验证成功");
                    let stepIndex = $("#next2-3").attr("step_index");
                    let stepId = '#step_' + stepIndex;
                    stepIndex++;
                    let divNextId = '#step_div_' + stepIndex;
                    let stepNextId = '#step_' + stepIndex;
                    $(stepId).hide();
                    $(stepNextId).show();
                    $(divNextId).addClass("Active");
                }else {
                    alert("验证失败");
                    $("[name='sms']").empty();
                }
            });


            /**
             * 完成
             */
            $("#next3-4").click(function () {
                var password1=$("[name='password1']").val();
                var password2=$("[name='password2']").val();
                if(password1==password2){
                    $.get("User/updatepassword",{"password":password1,"username":username},function (success) {
                        if(success==true){
                            alert("密码相同.修改密码成功");
                            let stepIndex = $("#next3-4").attr("step_index");
                            let stepId = '#step_' + stepIndex;
                            stepIndex++;
                            let divNextId = '#step_div_' + stepIndex;
                            let stepNextId = '#step_' + stepIndex;
                            $(stepId).hide();
                            $(stepNextId).show();
                            $(divNextId).addClass("Active");
                        }
                    });
                }else {
                    alert("密码不同,请重新输入");
                }
            });

            /**
             * 获取短信验证码
             */
            $("#sms").click(function () {
                alert("短信验证码是9172");
            });

            /**
             *四部已完成，单击”立即登录“进入login.html登陆页面
             */
            $("#entrynow").click(function () {
                window.location.href="login.html";
            });
            /**
             * 左上角logo，单击可以返回首页
             */
            $("#shouye").on("click", function () {

                window.location = "index.html?user="+user;
            });
        });

        // $(function () {
        //         $(".onebtn").on("click", function () {
        //             let stepIndex = $(this).attr("step_index");
        //             let stepId = '#step_' + stepIndex;
        //             stepIndex++;
        //             let divNextId = '#step_div_' + stepIndex;
        //             let stepNextId = '#step_' + stepIndex;
        //             $(stepId).hide();
        //             $(stepNextId).show();
        //             $(divNextId).addClass("Active");
        //         });
        //     });


    </script>

</head>
<body>
<div class="header">
    <div class="mainwarp">
        <div class="logo"><a id="shouye"><img src="images/log.png"/></a></div>
        <div class="welcome">重置密码</div>
        <div class="headerright">
            <a href="login.html">个人登录 </a>
            <span>|</span>
            <a href="index.html">返回首页</a>
        </div>
    </div>
</div>
<div class="passdBox">
    <div class="passpart1">
        <div class="TitleNotice">忘记密码了？根据收到的激活码进行验证身份，通过验证后重置密码，您就可以登录了。</div>
        <div class="StepsBox">
            <div id="step_div_1" class="Step Active stepfirst">
                <span class="StepNo">1</span>
                <span class="StepName">确认账户</span>
            </div>
            <div id="step_div_2" class="Step">
                <span class="StepNo">2</span>
                <span class="StepName">人机认证</span>
            </div>
            <div id="step_div_3" class="Step">
                <span class="StepNo">3</span>
                <span class="StepName">重置密码</span>
            </div>
            <div id="step_div_4" class="Step steplast">
                <span class="StepNo"></span>
                <span class="StepName">完成</span>
            </div>
        </div>
        <div class="clear"></div>
        <div id="step_1" class="restInfo">
            <div class="box1">
                <span>账   户：</span>
                <input name="loginword" type="text" placeholder="用户名/邮箱/已验证手机号"/>
                <div class="clear"></div>
            </div>
            <div class="box1">
                <span>验证码：</span>
                <input name="captcha" type="text" class="yzm"/>
                <img src="images/VerifyCode.jpg" width="100" height="35"/>
                <div class="clear"></div>
            </div>
            <div class="box1">
                <input id="next1-2" name="" type="button" step_index="1" class="onebtn" value="下一步"/>
            </div>
        </div>
        <div id="step_2" class="restInfo" hidden>
            <div class="box2" title="asa4"></div>
            <div class="box1">
                <span>激活码：</span>
                <input name="sms" type="text" class="yzm"/>
                <b id="sms" class="phonenum">获取短信验证码</b>
                <div class="clear"></div>
            </div>
            <div class="box1">
                <input id="next2-3" name="" type="button" step_index="2" class="onebtn" value="下一步"/>
            </div>
        </div>
        <div id="step_3" class="restInfo" hidden>
            <div class="box2">
                <span class="span1">用户名：</span>
                <span class="span2" title="asa6"></span>
                <div class="clear"></div>
            </div>
            <div class="box1">
                <span>新密码：</span>
                <input name="password1" type="text"/>
                <div class="clear"></div>
            </div>
            <div class="box1">
                <span>确认密码：</span>
                <input name="password2" type="text"/>
                <div class="clear"></div>
            </div>
            <div class="box1">
                <input id="next3-4" name="" type="button" step_index="3" class="onebtn" value="下一步"/>
            </div>
        </div>
        <div id="step_4" class="restInfo2" hidden>
            <div class="SucTitle">恭喜您，您的密码设置成功！</div>
            <p title="asa5"></p>
            <p>您可以使用新密码登录蝶飞人才网<a id="entrynow" >立即登录</a></p>
        </div>

    </div>
</div>
<div class="clear"></div>
</body>
</html>
